home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DRIVES.SWG / 0060_HD Test.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  2KB  |  67 lines

  1. {
  2. >  function GetDriveID(drive: char):byte;
  3. >  begin
  4. >    with regs do
  5. >      begin
  6. >        AH := $1C;
  7. >        DL := ord(Upcase(drive))-64;
  8. >        Intr($21,regs);
  9. >        GetDriveID := Mem[ds:bx];
  10. >      end;
  11. >  end;
  12.  
  13. >This interrupt (01Ch) is supposed to return 0F8h in case of a harddisk, and
  14. >some other value if it is a floppy. However, running OS/2, this function
  15. >returns 0F0h :(( My old Apricot (it's a computer!), running DOS 3.2, also
  16. >reports 0F0h...
  17.  
  18.   0F0H is also the code for an unknown device for Service $1C.  I
  19.   haven't tried it but have you looked at Service $44, function $08?  My
  20.   sources tell me that this function (DOS 3.0 up) will return 0 in AX if
  21.   the device is removable, 1 if a fixed disk, and $0F if invalid drive.
  22.  
  23.   Hang on... I'm trying it now.  It seemed to work here.  Below is the
  24.   sample code I used (in TP 5.5).
  25. }
  26.  
  27. PROGRAM HDTest;
  28. {Stuart Kirschenbaum 93/12/11 Donated to the Public Domain if
  29.   the Public actually wants it :-)  }
  30.  
  31. USES
  32.    DOS;
  33.  
  34. VAR
  35.   Is_Hard_Drive : boolean;
  36.  
  37. FUNCTION TestHD(DriveNum : byte):boolean;
  38. VAR
  39.    Regs: Registers;
  40. BEGIN
  41.    With Regs DO BEGIN
  42.       AH := $44;
  43.       AL := $08;
  44.       BL := DriveNum;
  45.       Intr($21, Regs);
  46.       IF AX = 0 THEN TestHD := false
  47.       ELSE IF AX = 0 THEN TestHD := true;  {Note we really should test
  48.                                             for invalid drive but this
  49.                                             is just an example <g> }
  50.    END;
  51.  
  52. END;
  53.  
  54. BEGIN {Main for testing program}
  55.  
  56.    Is_Hard_Drive := TestHD(3); {3 = Drive C a Hard Drive on my system}
  57.    IF Is_Hard_Drive THEN
  58.       writeln('Well that seemed to work fine... Let''s try a floppy')
  59.    ELSE
  60.       writeln('That didn''t work right... Damn.');
  61.    Is_Hard_Drive := TestHD(1); {1 = Drive A, a floppy drive}
  62.    IF Is_Hard_Drive THEN
  63.       writeln('You should never see this message')
  64.    ELSE
  65.       writeln('Success');
  66. END.
  67.